//
//  DestTabBarTwoImageTableViewCell.m
//  TravelEveryDay
//
//  Created by dlios on 15/10/15.
//  Copyright © 2015年 com.lanou3g. All rights reserved.
//

#import "DestTabBarTwoImageTableViewCell.h"
#import "BaseHeader.h"
#import "DestTabBarTwoImageCollectionViewCell.h"
#import "DestTabBarModel.h"
@implementation DestTabBarTwoImageTableViewCell

- (void)awakeFromNib {
    // Initialization code
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        _destFlowLayout = [[UICollectionViewFlowLayout alloc]init];
        _destFlowLayout.itemSize = CGSizeMake(175 *WIDTH, 175 *WIDTH);
        _destFlowLayout.minimumInteritemSpacing = 5 * HEIGHT;
        _destFlowLayout.minimumLineSpacing = 5 * WIDTH;
        _destFlowLayout.sectionInset = UIEdgeInsetsMake(10 * WIDTH , 10 *WIDTH , 10  * WIDTH, 10 * WIDTH );
        _destTabBarCollectionView  = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, (SCREEN_WIDTH -25 *WIDTH)/2 +25 *WIDTH) collectionViewLayout:_destFlowLayout];
        _destTabBarCollectionView.backgroundColor = [UIColor whiteColor];
        _destTabBarCollectionView.delegate = self;
        _destTabBarCollectionView.dataSource =self;
        _destTabBarCollectionView.bounces = NO;
        _destTabBarCollectionView.showsHorizontalScrollIndicator = NO;
        _destTabBarCollectionView.backgroundColor =[UIColor colorWithRed:251/255. green:246/255. blue:233/255. alpha:1];
        [_destTabBarCollectionView registerClass:[DestTabBarTwoImageCollectionViewCell class] forCellWithReuseIdentifier:@"destTabBarTwoImageCollectionViewCell"];
        [self.contentView addSubview:_destTabBarCollectionView];
    }
    return self;
}
-(void)setDestSectionModelArray:(NSMutableArray *)destSectionModelArray {
    _destSectionModelArray =  destSectionModelArray;
    [_destTabBarCollectionView reloadData];
}
#pragma mark - collection代理方法 : 返回item个数
- (NSInteger )collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return _destSectionModelArray.count;
}
#pragma mark  - collection代理方法 : 返回cell种类
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    DestTabBarTwoImageCollectionViewCell *destTabBarcell = [collectionView dequeueReusableCellWithReuseIdentifier:@"destTabBarTwoImageCollectionViewCell" forIndexPath:indexPath];
    DestTabBarModel *destMdoel = [_destSectionModelArray objectAtIndex:indexPath.row];
    destTabBarcell.destModel = destMdoel;//传值
    return destTabBarcell;
}
#pragma mark - collection的点击方法 设置代理用到的
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    DestTabBarModel *destMdoel = [_destSectionModelArray objectAtIndex:indexPath.row];
    ///代理人调用代理方法
    [self.delegate collectionTwoDidselected:destMdoel.MyId TwocellIndex:2 TwoMyType:destMdoel.type];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
